package com.edu.koTA07.takingOrder;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.widget.Toast;

public class DatabaseHelper extends SQLiteOpenHelper
{

            public static final int DB_version = 1;
            public static final String DB_name = "User";
            public SQLiteDatabase database;
            public static final String TABLE_NAME = "tbl_users";
            //public static final String TABLE_NAME = "tbl_temp";
            public static final String CREATE_USER_TABLE = "CREATE TABLE"+TABLE_NAME+"(id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT, username TEXT, password TEXT, email TEXT);";
            LogIn login = new LogIn();
            public DatabaseHelper(Context context, String name, CursorFactory factory,int version)
            {
                super(context, DB_name, factory,DB_version);
                // TODO Auto-generated constructor stub
            }

            @Override
			public void onCreate(SQLiteDatabase db)
                {

                        Toast.makeText(login.getApplicationContext(),"In Helper executing onCreate()", Toast.LENGTH_SHORT).show();
                        // Create the table
		                db.execSQL("DROP TABLE IF EXISTS tbl_users");
		                db.execSQL(CREATE_USER_TABLE);

                }

                @Override
                public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
                        // Housekeeping here.
                        // Implement how "move" your application data during an upgrade of schema versions
                        // There is no ALTER TABLE command in SQLite, so this generally involves
                        // CREATING a new table, moving data if possible, or deleting the old data and starting fresh
                        // Your call.
                        //db.execSQL("DROP TABLE IF EXISTS tbl_users");
                        //onCreate(database);
                }

                @Override
                public void onOpen(SQLiteDatabase db) {
                        super.onOpen(db);
                }
        }
